package com.demo.modules.file.config;

import com.demo.modules.file.common.constants.FileConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author MyPC
 */
@Configuration
public class WebMvcConfigFile implements WebMvcConfigurer {

    @Autowired
    private FileConstants fileConstants;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //图片的资源映射
        registry.addResourceHandler(fileConstants.getPrefix() + "/**").addResourceLocations(
                "file:" + fileConstants.getPath() + "/");
    }
}
